import http from '../request';
const apibase = '/api/Material';
import qs from 'qs';
//获取物料
var getMaterials = function (data) {
  return new Promise ((resolve, reject) => {
    http
      .post (apibase + `/getMaterials`, data)
      .then (res => {
        resolve (res);
      })
      .catch (error => {
        reject (error);
      });
  });
};
//查询物料
var getMaterialSearch = function (data) {
  return new Promise ((resolve, reject) => {
    http
      .post (apibase + `/GetMaterialSearch`, data)
      .then (res => {
        resolve (res);
      })
      .catch (error => {
        reject (error);
      });
  });
};
//查询物料
var getMaterial = function (data) {
  return new Promise ((resolve, reject) => {
    http
      .post (apibase + `/GetMaterial`, data)
      .then (res => {
        resolve (res);
      })
      .catch (error => {
        reject (error);
      });
  });
};
//根据物料类型获取物料及子级物料
var getMaterialsByParentNode = function (data) {
  return new Promise ((resolve, reject) => {
    http
      .post (apibase + `/GetMaterialsByParentNode`, data)
      .then (res => {
        resolve (res);
      })
      .catch (error => {
        reject (error);
      });
  });
};
//获取全部物料
var GetMaterialList = function (data) {
  return new Promise ((resolve, reject) => {
    http
      .post (apibase + `/GetMaterialList`, data)
      .then (res => {
        resolve (res);
      })
      .catch (error => {
        reject (error);
      });
  });
};
//获取全部物料类型
var GetMaterialTypeList = function (data) {
  return new Promise ((resolve, reject) => {
    http
      .post (apibase + `/GetMaterialTypeList`, data)
      .then (res => {
        resolve (res);
      })
      .catch (error => {
        reject (error);
      });
  });
};
//修改物料信息
var EditMaterial = function (data) {
  return new Promise ((resolve, reject) => {
    http
      .post (apibase + `/EditMaterial`, data)
      .then (res => {
        resolve (res);
      })
      .catch (error => {
        reject (error);
      });
  });
};
//同步订单
var SynchroMaterial = function () {
  return new Promise ((resolve, reject) => {
    http
      .post (apibase + `/SynchroMaterial`)
      .then (res => {
        resolve (res);
      })
      .catch (error => {
        reject (error);
      });
  });
};
//上传EXECL
var InMaterial = function (data) {
  return new Promise ((resolve, reject) => {
    http
      .Filepost (apibase + `/InMaterial`, data)
      .then (res => {
        resolve (res);
      })
      .catch (error => {
        reject (error);
      });
  });
};
//下载
var MaterialDownload = function (data) {
  return new Promise ((resolve, reject) => {
    http
      .post (apibase + `/MaterialDownload?ParentNode`, data)
      .then (res => {
        resolve (res);
      })
      .catch (error => {
        reject (error);
      });
  });
};
export {
  GetMaterialList,
  EditMaterial,
  SynchroMaterial,
  getMaterials,
  getMaterialSearch,
  InMaterial,
  MaterialDownload,
  getMaterial,
  GetMaterialTypeList,
  getMaterialsByParentNode,
};
